package com.example.wanghao.wangyixinwen.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.wanghao.wangyixinwen.R;
import com.example.wanghao.wangyixinwen.bean.PicBean;

import java.util.List;

/**
 * Created by wanghao on 2016/5/24.
 */
public class PicAdapter extends MyBaseAdapter<PicBean.DataBean.NewsBean>{
    public PicAdapter(List<PicBean.DataBean.NewsBean> datas, Context context) {
        super(datas, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PicBean.DataBean.NewsBean newsBean = mDatas.get(position);
        if (convertView == null){
           convertView = View.inflate(mContext, R.layout.photo_item,null);
       }

        ImageView iv = (ImageView) convertView.findViewById(R.id.iv_photoitem_image);
        TextView tv = (TextView) convertView.findViewById(R.id.tv_photoitem_title);

        tv.setText(newsBean.title);
        Glide.with(mContext.getApplicationContext()).load(newsBean.listimage).into(iv);
        return convertView;
    }
}
